<template>
  <div style="background-color: #f5f5f5; padding-bottom: 20px">
    <!-- <div class="in-Image">
      <a-carousel>
        <div>
          <img src="@/assets/image/employment/marshalling.png" alt="" />
        </div>
      </a-carousel>
      轮播图完
    </div> -->
    <!-- 面包屑 -->
    <div style="width: 1200px; padding: 20px 0; margin: 0 auto">
        <a-breadcrumb separator=">">
            <a-breadcrumb-item href="/" @click.native="$router.push('/')">首页</a-breadcrumb-item>
            <a-breadcrumb-item style="color: #FFBE37;">通知公告</a-breadcrumb-item>
        </a-breadcrumb>
    </div>
    <div class="notice">
      <div class="noticeTitle">
        <div class="sign"></div>
        <p>通知公告</p>
        <div class="dlex2-div" style="width: 335px">
          <a-input
            style="width: 250px; height: 38px !important"
            v-model="title"
            placeholder="请输入关键字"
            class="searchInput"
          />
           <div
            class="searchIcon"
            style="padding: 11px; height: auto; width: auto"
            @click="onSearch()"
          >
            <img style="width: 16px" src="@/assets/image/icon1.png" alt="" />
            <span>搜索</span>
          </div>
        </div>
      </div>
      <div class="not-txt">
        <div
          class="nottxt-top"
          v-for="(item, index) in notArr"
          :key="index+'aa'"
          @click="getDescribe(item.newsNo, '通知公告')"
        >
          <div class="yuan">
            <i
              style="
                width: 6px;
                height: 6px;
                border-radius: 50%;
                background-color: #999999;
                display: block;
              "
            ></i>
            <span>{{ item.title }}</span>
          </div>

          <span>{{ item.publishTime }}</span>
        </div>
        <a-empty
          :image="imgUrl"
          :image-style="{
            height: '220px',
          }"
          v-if="notArr.length == 0 && flag"
        />
      </div>
      <div class="bottom">
        <!-- -->
        <div class="cnBottom" v-if="notArr.length > 1">
          <div style="margin: 0 auto; width: 230px">
            <a-button @click="more()" v-show="btnState == 1" class="sobtn"
              >点击加载更多</a-button
            >
            <a-button v-show="btnState == 2" class="sobtn" :loading="true"
              >正在加载中</a-button
            >
            <span class="timeTxt1" v-if="btnState == 3">没有更多了</span>
          </div>
        </div>
      </div>
      <!-- <a-pagination
        style="text-align: center; margin-top: 90px"
        :pageSize="pageSize"
        @change="turnPages"
        :hideOnSinglePage="true"
        :total="totalnbr"
        show-less-items
      /> -->
      <!-- 分页结束 -->
    </div>
    <Loading v-show="onLoading"></Loading>
  </div>
</template>
<script>
// 字符转换
// function str2utf8(str) {
//     let encoder = new TextEncoder('utf8');
//     return encoder.encode(str);
// }
export default {
  name: "productdetailspage",
  data() {
    return {
      // 怕版权影响换张图片
      imgUrl: require("@/assets/image/pagint.png"),
      title:"", //关键字搜索
      // 总页数
      totalnbr: 0,
      pageSize:8,
      pageIndex:1,
      notArr: [],
      flag:false,
      btnState:1,
      onLoading:false
    };
  },
  methods: {
    // 加载更多
    more() {
      this.btnState = 2;
      this.pageIndex++;
      this.selHomeNoticeList();
    },
    onSearch(e){
      this.pageIndex = 1;
      this.flag = false;
      this.notArr = [];
      this.selHomeNoticeList();
    },
    callback(key) {
      // console.log(key);
      if (key == "1") {
        key = 18;
        key = Number(key);
        this.selCadreNoticeList(key);
      } else {
        key = 19;
        key = Number(key);
        this.selCadreNoticeList(key);
      }
    },
    // 翻页
    turnPages(e) {
      this.pageIndex = e;
      this.selHomeNoticeList();
    },

    // 跳转函数
    getDescribe(e, i) {
      //  直接调用$router.push 实现携带参数的跳转
      this.$router.push("/details/details?from=2&id=" + e + "&type=" + i);
    },
    // 新闻通知公告列表调用
    selHomeNoticeList() {
      this.onLoading = true
      this.$ajax({
        url: "/news/newsmsg/list/notice?pageSize="+this.pageSize+"&pageIndex="+this.pageIndex,
        method: 'post',
        params:{
          title: this.title
        }
      }).then((res) => {
        this.flag = true;
        if (res.code == "200") {
          this.onLoading = false
          let notArr = [...this.notArr, ...res.data.list]
          this.$set(this, 'notArr', notArr)
          // console.log(this.notArr)
          this.totalnbr = res.data.totalCount;
          if(this.totalnbr<this.pageIndex * this.pageSize){
            this.btnState = 3;
          } else {
            this.btnState = 1;
          }
        } else {
          this.onLoading = false
          this.notArr = [];
        }
      });
    },
  },
  mounted() {
    this.selHomeNoticeList();
  },
};
</script>
<style lang="less" scoped>
.in-Image {
  width: 100%;
  img {
    width: 100%;
  }
}
// 头部结束
.txt3 {
  width: 140px;
  height: 36px;
  float: left;
  padding-left: 40px;
  position: relative;
  left: -17px;
  background-size: 100% 100%;
  p {
    width: 80%;
    height: 100%;
    display: block;
    margin: 0;
    overflow-wrap: break-word;
    color: rgba(255, 255, 255, 1);
    font-size: 18px;
    font-family: PingFangSC-Regular;
    white-space: nowrap;
    text-align: center;
    line-height: 36px;
  }
}
.notice {
  width: 1200px;
  min-height: calc(100vh - 381px);
  margin: 0 auto;
  background-color: #ffffff;
  // margin-top: 30px;
  padding: 34px 32px 50px;
  .noticeTitle{
    display: flex;
    justify-content: space-between;
    position: relative;
    margin-bottom: 25px;
    p{
      line-height: 40px;
      color:#333333;
      font-size: 24px;
      font-weight: bold;
      padding-left: 13px;
    }
    .sign{
      width: 4px;
      height: 14px;
      background: #FFBE37;
      position: absolute;
      bottom: 10px;
    }
  }
  a {
    color: #050505;
  }
  a:hover {
    color: #ca0000;
  }
  .notNav {
    width: 80%;
    // background-color: darkgreen;
    margin: 0 auto;
  }
  .txt1 {
    width: 82px;
    display: block;
    overflow-wrap: break-word;
    color: rgba(51, 51, 51, 1);
    font-size: 18px;
    letter-spacing: 2.3684210777282715px;
    font-family: PingFangSC-Regular;
    white-space: nowrap;
    line-height: 50px;
    text-align: center;
  }
}
// 分割
.not-txt {
  overflow: hidden;
  margin: 0 auto;
  min-height: 450px;
  span {
    color: #666666;
    font-size: 16px;
  }
  .nottxt-top {
    display: flex;
    align-items: center;
    padding-left: 32px;
    padding-right: 32px;
    height: 58px;
    line-height: 58px;
    display: flex;
    align-content: center;
    cursor: pointer;
    &:first-child {
      margin-top: 0px;
    }
    &:nth-child(2n+1){
      background: #F8F8F8;
    }
  }
}
.yuan {
  display: flex;
  height: 20px;
  align-items: center;
  flex: 1;
  span {
    transition: color 0.3s linear;
    margin-left: 16px;
  }
  span:hover {
    color: @theme;
  }
}
// paging部分
.paging {
  // width: 100%;
  height: 40px;
  margin-top: 162px;
  margin-left: 30%;
}
.cFbom3 {
  width: 1200px;
  margin: 0 auto;
  height: 50px;
}
</style>
